import { nanoid } from 'nanoid'
import request, { MockResult } from '../request'
const baseUrl = '/spd-eatonos-service'

export const file = {
  // 获取菜单
  getUploadData (data) {
    return request({
      url: baseUrl + '/file/getUploadData',
      method: 'post',
      data,
      mock: {
        useMock: true,
        data: MockResult.success({
          url: 'upload-file',
          uuid: nanoid(),
          fileName: 'fileName'
        })
      }
    })
  },
  confirmUpload (params) {
    return request({
      url: baseUrl + '/file/confirmUpload',
      method: 'get',
      params,
      mock: {
        useMock: true,
        data: MockResult.success({
          file: params
        })
      }
    })
  },
  uploadFile (data) {
    return request({
      url: baseUrl + '/file/uploadFile',
      method: 'post',
      data,
      mock: {
        useMock: true,
        data: MockResult.success({
          file: 'file upload success'
        })
      }
    })
  }
}

export default file